package com.risenb.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.risenb.bean.Permission;
import com.risenb.bean.PermissionRole;
import com.risenb.dao.PermissionMapper;
import com.risenb.dao.PermissionRoleMapper;
import com.risenb.service.PermissionRoleService;
@Service(value = "permissionRoleService")
public class PermissionRoleServiceImpl implements PermissionRoleService {
	
	@Autowired
	PermissionMapper permissionMapper;
	
	@Autowired
	PermissionRoleMapper permissionRoleMapper;
	
	@Override
	public List<PermissionRole> queryPermissionRoleByRoleById(Integer roleId) {
		List<PermissionRole> prs = permissionRoleMapper.queryPermissionRoleByRoleById(roleId);
		for (int i = 0; i < prs.size(); i++) {
			Permission p = permissionMapper.queryPermissionById(prs.get(i).getPermissionid());
			prs.get(i).setPermission(p);
		}
		return prs;
	}
	@Override
	public int removePermissionRoleByRoleId(Integer roleid) {
		return permissionRoleMapper.removePermissionRoleByRoleId(roleid);
	}
	@Override
	public int createPermissionRole(PermissionRole record) {
		return permissionRoleMapper.createPermissionRole(record);
	}

}
